import { requestClient } from '#/api/request';

export namespace workstationAPI {
  export interface Workstation {
    code: number;
    msg: string;
    rows: [];
    total: number;
  }

  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date | null;
    remark: any;
    params: any;
    workstationId: number;
    workstationCode: string;
    workstationName: string;
    workstationAddress: null | string;
    workshopId: number;
    workshopCode: string;
    workshopName: string;
    processId: number;
    processCode: string;
    processName: string;
    warehouseId: number;
    warehouseCode: any;
    warehouseName: any;
    locationId: number;
    locationCode: any;
    locationName: any;
    areaId: number;
    areaCode: any;
    areaName: any;
    enableFlag: any;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }
  export interface workshopAll {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

export const getWorkstationList = (params?: {
  itemTypeId?: number;
  page?: number;
  pageSize?: number;
}) => {
  return requestClient.get<workstationAPI.Workstation>(
    '/mes/md/workstation/list',
    {
      params,
    },
  );
};

// 删除工作站
export const deleteWorkstation = (id: string) => {
  return requestClient.delete<workstationAPI.workshopAll>(
    `/mes/md/workstation/${id}`,
  );
};
// 新增工作站
export const addWorkstation = (data: workstationAPI.Row) => {
  return requestClient.post<workstationAPI.workshopAll>(
    '/mes/md/workstation',
    data,
  );
};

// 修改工作站
export const updateWorkstation = (data: workstationAPI.Row) => {
  return requestClient.put<workstationAPI.workshopAll>(
    '/mes/md/workstation',
    data,
  );
};
